<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>前端监控SDK</title>
</head>
<body>
  <div class="container">
    <div id="content">
        <input id="err" type="button" value="点击抛出错误" onclick="errorClick()">
        <input type="button" value="点击抛出错误" onclick="promiseErrorClick()">
        <input type="button" value="ajax成功请求" onclick="sendSuccess()">
        <input type="button" value="ajax失败请求" onclick="sendError()">
    </div>
  </div>
  <script>
    function errorClick(){
      window.someVar.error='error'
    }
    
    function promiseErrorClick(){
      return new Promise((resolve, reject) => {
      window.someVar.error='error'
          //  reject('error')
      })
    }
    function sendSuccess(){
      let xhr = new XMLHttpRequest();
      xhr.open('GET','/success',true)
      xhr.responseType = 'json'
      xhr.onload = function(){
        console.log('suc');
      }
      xhr.onerror=(err)=>{
        console.log('err',err);
      }  
      xhr.send()
    }
    function sendError(){
      let xhr = new XMLHttpRequest();
      xhr.open('GET','/error',true)
      xhr.responseType = 'json'
      xhr.onload = function(){
        console.log('suc');
      }
      xhr.onerror=(err)=>{
        console.log('err',err);
      }  
      xhr.send()
    }
  
  document.addEventListener('DOMContentLoaded',()=>{
    let start = Date.now();
    while((Date.now() - start) < 1000){
    }
  })
  setTimeout(()=>{
    let h1 = document.createElement('h1')
    let content = document.getElementById('content')
    h1.innerHTML = '我是这个页面最有意义的属性'
    h1.setAttribute('elementtiming','meaningful')
    content.appendChild(h1)
  },3000)
  </script>
  <!-- <script  src="./test.js"></script> -->
 
</body>
</html>